﻿@Html.DevExpress().GridView(
            settings =>
            {
                settings.Name = "gvEditing2";
                settings.KeyFieldName = ViewData["KeyColumns"].ToString();
                settings.CallbackRouteValues = new { Controller = "TaxDataCompare", Action = "SYDataPartial" };
                settings.Width =System.Web.UI.WebControls.Unit.Percentage(100);
                if (ViewData["showDt"] != null)
                {
                    foreach (System.Data.DataColumn dc in (ViewData["showDt"] as System.Data.DataTable).Columns)
                    {
                        settings.Columns.Add(dc.ColumnName, dc.Caption);
                    }
                }
                else
                {
                    settings.Columns.Add("操作", ViewData["KeyColumns"].ToString());
                }
                settings.SettingsBehavior.AllowSort = false;
                settings.SettingsBehavior.AllowDragDrop = false;
                settings.SettingsBehavior.AllowSelectByRowClick = false;
                settings.SettingsLoadingPanel.Text = "数据读取中...";
                settings.SettingsBehavior.AllowClientEventsOnLoad = false;
                settings.SettingsBehavior.AllowFocusedRow = true;

                settings.ClientSideEvents.BeginCallback = "function(s,e){OnBeginCallback(s,e)}";
                settings.CommandColumn.Visible = false;

                settings.PageIndexChanged = (sender, e) =>
                {
                    ASPxGridView grid = (ASPxGridView)sender;
                    grid.Selection.UnselectAll();
                };
                settings.DataBinding = (sender, e) =>
                {
                    ASPxGridView grid = (ASPxGridView)sender;
                    for (int i = 0; i < grid.AllColumns.Count; i++)
                    {
                        if (grid.AllColumns[i].CellStyle.HorizontalAlign == System.Web.UI.WebControls.HorizontalAlign.NotSet)
                        {
                            grid.AllColumns[i].CellStyle.HorizontalAlign = System.Web.UI.WebControls.HorizontalAlign.Center;
                        }
                        if (grid.AllColumns[i].HeaderStyle.HorizontalAlign == System.Web.UI.WebControls.HorizontalAlign.NotSet)
                        {
                            grid.AllColumns[i].HeaderStyle.HorizontalAlign = System.Web.UI.WebControls.HorizontalAlign.Center;
                        }
                    }
                };                                       
                
            }).Bind(Model).GetHtml()
